package com.serookie.controller;

import com.serookie.entity.Order;
import com.serookie.entity.Result;
import com.serookie.entity.SysUser;
import com.serookie.entity.WxUser;
import com.serookie.service.WxUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author kevintam
 * @version 1.0
 * @date 2021/5/31 20:32
 */
@RestController
@Api(value = "微信的用户",tags = "微信用户的对象类")
public class WxUserController{

    @Autowired
    private WxUserService wxUserService;

    @PostMapping("/wxLogin")
    @ApiOperation("微信的登录")
    public Result wxLogin(String code,HttpServletRequest request){
        String avatar = request.getParameter("avatar");
        String nickName = request.getParameter("nickName");
        String gender = request.getParameter("gender");
        SysUser user = new SysUser();
        user.setAvatar(avatar);
        user.setName(nickName);
        user.setName(gender);
        return wxUserService.WxLogin(code,user,request);
    }
    @GetMapping("/wx/user/all")
    @ApiModelProperty("wx用户")
    public Result all(){
        List<WxUser> all = wxUserService.all();
        return Result.ok().message("操作成功").data("all",all);
    }
}
